package com.huawei.appgallery.assistantdock.gamemode.card;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.hmf.orb.exception.ConnectRemoteException;
import o.beo$d;
import o.beo.f;
import o.bif.d;
import o.biu;
import o.cgz;
import o.Logger;
import o.eyb;
import o.fae;
import o.fam;
import o.ffa;
import o.ffd;
import o.ffp;
import o.fho;
import o.fho.b;
import o.fhz;
import o.fjo;
import o.fjq;

public class NetOptimizationEnterCardBuoy extends BuoyBaseEnterCard {
    private GameInfo ʻ;
    private Context ʽ;

    public NetOptimizationEnterCardBuoy(Context context) {
        super(context);
        this.ʽ = context;
    }

    public cgz ˏ(View view) {
        cgz ˏ = super.ˏ(view);
        this.ˊ.setText(f.ˑ);
        this.ʼ.setBackgroundResource(beo$d.ˎˎ);
        fae ˏ2 = fam.ॱ().ˏ();
        if (ˏ2 != null) {
            this.ʻ = ˏ2.getGameInfo();
        } else {
            Logger.e("NetOptimizationEnterCardBuoy", "buoyBridge == null");
        }
        return ˏ;
    }

    public void ˏ(CardBean cardBean) {
        ˋ(biu.ˋ().ˋ(this.ʻ));
        super.ˏ(cardBean);
        ˏॱ();
    }

    public void ˋ() {
        Intent intent = new Intent("com.huawei.netaccelerateprotocolactivity");
        intent.setPackage("com.huawei.gameassistant");
        intent.addFlags(268435456);
        this.ʼॱ.startActivity(intent);
        if (this.ʽ == null) {
            Logger.e("NetOptimizationEnterCardBuoy", "context == null");
        } else {
            fam.ॱ().ˏ(this.ʽ);
        }
        ˏ("CLICK");
    }

    private void ˏॱ() {
        final ffa o_ffp = new ffp(this.ʼॱ, "com.huawei.gameassistant");
        fho.ˋ(o_ffp, new b(this) {
            final /* synthetic */ NetOptimizationEnterCardBuoy ˋ;

            public void ˏ(ffd o_ffd, ConnectRemoteException connectRemoteException) {
                if (connectRemoteException != null) {
                    Logger.e("NetOptimizationEnterCardBuoy", "connect exception");
                    this.ˋ.ॱ(false);
                    return;
                }
                fhz ˋ = o_ffd.ˋ("buoysettingmodule");
                if (ˋ == null) {
                    Logger.e("NetOptimizationEnterCardBuoy", "Module Name:buoysettingmodule is null");
                    this.ˋ.ॱ(false);
                    return;
                }
                eyb o_eyb = (eyb) ˋ.ॱ(eyb.class);
                if (o_eyb == null) {
                    Logger.e("NetOptimizationEnterCardBuoy", "buoyWindowManager is null");
                    this.ˋ.ॱ(false);
                    return;
                }
                fae ˏ = fam.ॱ().ˏ();
                if (ˏ != null) {
                    final GameInfo gameInfo = ˏ.getGameInfo();
                    if (gameInfo != null) {
                        o_eyb.ˋ(gameInfo.getPackageName()).ˏ(new fjq<Boolean>(this) {
                            final /* synthetic */ AnonymousClass4 ˎ;

                            public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                                if (!o_fjo_java_lang_Boolean.ˊ()) {
                                    this.ˎ.ˋ.ॱ(false);
                                } else if (((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                                    this.ˎ.ˋ.ॱ(true);
                                    biu.ˋ().ˏ(gameInfo, true);
                                } else {
                                    if (Logger.ˎ()) {
                                        Logger.ˏ("NetOptimizationEnterCardBuoy", "not support net optim");
                                    }
                                    this.ˎ.ˋ.ॱ(false);
                                    biu.ˋ().ˏ(gameInfo, false);
                                }
                            }
                        });
                    } else {
                        this.ˋ.ॱ(false);
                    }
                } else {
                    this.ˋ.ॱ(false);
                }
                o_ffp.ॱ();
            }
        });
    }

    private void ॱ(boolean z) {
        ˋ(z);
        ˊ();
    }

    String ᐝ() {
        return d.GSS_NET_OPTIM.ˊ();
    }
}
